package com.pybox.repository;

import com.pybox.dto.Result;
import com.pybox.entity.TCanbinetEventLogs;
import io.swagger.models.auth.In;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
* 描述：TCanbinetEventLogs Repository
* @author wuyingkai
* @date 2018-09-15
*/

@Repository
public interface TCanbinetEventLogsRepository extends JpaRepository<TCanbinetEventLogs, Integer>, JpaSpecificationExecutor<TCanbinetEventLogs>   {

    @Modifying
    @Query(value = "update t_canbinet_event_logs set  state = 1 where  (level=2  or level =3) and id =?", nativeQuery = true)
    Integer updateStateById(Integer Id);

    @Modifying
    @Query(value = "update t_canbinet_event_logs set  state = 1 where  (level=2  or level =3) ", nativeQuery = true)
    Integer updateAllState();

    @Query(value = "select count(1) from t_canbinet_event_logs where  state =0 and (level=2  or level =3)  and customer_id = ?1",nativeQuery = true)
    Integer  getUnCheckCount(Integer customerId);

    @Query(value = "select count(1) from t_canbinet_event_logs where  state =0 and (level=2  or level =3) ",nativeQuery = true)
    Integer  getUnCheckCount();
}